package com.xiaoyu.base.event;

import com.xiaoyu.base.BuildConfig;

import in.srain.cube.request.FailData;
import in.srain.cube.util.CLog;

public class BaseEvent {

    private boolean mFailed;
    private FailData mFailData;

    public boolean isFailed() {
        return mFailed;
    }

    @Deprecated
    public BaseEvent fail() {
        mFailed = true;
        return this;
    }

    public BaseEvent fail(FailData failData) {
        mFailed = true;
        return this;
    }

    public FailData getFailData() {
        return mFailData;
    }

    public void post() {
        if (BuildConfig.DEBUG) {
            final String[] className = ((Object) this).getClass().getName().split("\\.");
            CLog.d("cp-event", "%s, %s", className[className.length - 1], this);
        }
        AppEventBus.getInstance().post(this);
    }

    public void postSticky() {
        if (BuildConfig.DEBUG) {
            final String[] className = ((Object) this).getClass().getName().split("\\.");
            CLog.d("cp-event", "sticky %s, %s", className[className.length - 1], this);
        }
        AppEventBus.getInstance().postSticky(this);
    }
}